package com.springboot.java.design.composite;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: TongRui乀
 * @Date: 2019-12-12 17:43
 * @description：  容器构件
 */
@Slf4j
public class FolderFile extends AbstractFile {

    String name;

    List<AbstractFile> files = new ArrayList<AbstractFile>();

    public FolderFile(String name){
        this.name = name;
    }

    @Override
    public void addFile(AbstractFile file) {
        files.add(file);
    }

    @Override
    public void deleteFile(AbstractFile file) {
        files.remove(file);
    }

    @Override
    public void kill() {
        files.forEach(AbstractFile::kill);
    }
}
